package com.baitengsoft.patentservicemonitor.job.cloud;

import com.aliyun.oss.OSSClient;
import com.baitengsoft.patentservicemonitor.job.cloud.download.InitAliYunDataService;
import com.baitengsoft.patentservicemonitor.job.cloud.download.InitAliYunOutDataService;
import com.baitengsoft.patentservicemonitor.job.cloud.download.InitAliYunUpdateDataService;

import com.baitengsoft.patentservicemonitor.job.utils.HttpUtils;
import com.baitengsoft.patentservicemonitor.job.utils.SysParametersUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;


/**
 * 阿里云存储
 *
 * @author KennyGu
 * @email 89335272@qq.com
 * @date 2017-12-26 16:22
 */
@Service("aliyunCloudStorageService")
public class AliyunCloudStorageService {
//
//    @Autowired
//    private PacPatentinfoService pacPatentinfoService;

    private OSSClient client;
    @Autowired
    private CloudStorageConfig config;
//    private static final Pattern NAMES = Pattern.compile("(.*?)([^/]+)/?$");

    private final Logger logger = LoggerFactory.getLogger(AliyunCloudStorageService.class);



    @Autowired
    private SysParametersUtil sysParametersUtil;

    @Autowired
    private InitAliYunDataService initService;

    @Autowired
    private InitAliYunOutDataService initOutService;

    @Autowired
    private InitAliYunUpdateDataService initUpdateService;



    //分页获取所有Object，每页maxKeys条Object。------初始化--区域内数据
    public String InitPatentListfor(Integer pid) {
        initService.batchInsert(pid);
        return "";
    }


    //分页获取所有Object，每页maxKeys条Object。------初始化--转出区域的数据

    public String InitPatentoutListfor(Integer pid) {
        initOutService.fetchData(pid);
        return  "";

    }



    /**
     * 文件更新
     *
     * @param pid
     * @return
     */
    public String fileListbyupdate(Integer pid) {
        initUpdateService.fetchData(pid);
        return "";

    }


    /**
     * 调用接口，生成报表
     * @param platformId
     */
    public void excuteRun(long platformId) {
        String url = sysParametersUtil.getAddOrUpdateRptUrl();
        HttpUtils.get(url + "?webPlatformId=" + platformId);

    }
}
